-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create utils and Jupiter extension to reset Logback #468
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Add LogbackTestHelpers utility class. This provides utilities to reset Logback. * Add ResetLogbackLoggingExtension, a Jupiter extension to reset Logback after all tests have run. * Add UncheckedJoranException, which wraps the checked Logback JoranException. * Update several tests that use Dropwizard extensions to use ResetLogbackLoggingExtension to restore logging. Closes #460 Closes #461
* Remove redundant throws clauses * Replace duplicate code in InMemoryAppenderExtension with call to LogbackTestHelpers#resetLogback * Make visibility of Dropwizard Configuration classes in several tests the same as the Application class * Suppress "throwable not thrown" in UncheckedJoranExceptionTest
* Remove public modifier from LogbackTestHelpersIntegrationTest * Fix javadoc typo and grammar in LogbackTestHelpersIntegrationTest
* Sonar java:S3551 - make UncheckedJoranException#getCause synchronized to math the synchronization of Throwable#getCause. While I get what Sonar is saying, I'm not entirely convinced this is really an issue. For example, why does java.io.UncheckedIOException override getCause but NOT make it synchronized? But go ahead and make Sonar happy...
* Make resetLogback() try logback-test.xml, then logback.xml as fallback * Add varargs argument to resetLogback so that it accepts a primary location, and optionally fallback locations
All it does right now is validate withLogbackConfigFilePath
* Make logbackConfigFilePath final in ResetLogbackLoggingExtension * Add test that verifies default and custom config locations
The reason to do this is to provide more flexibility. Unless a custom Logback config file is provided, use the LogbackTestHelpers.resetLogback() method which attempts both logback-test.xml with logback.xml as a fallback.
Add LogbackTestHelper which mainly delegates to LogbackTestHelpers. It adds a new method, resetLogbackWithDefaultOrConfig, which removes the duplicate conditional logic in the InMemoryAppenderExtension and the ResetLogbackLoggingExtension. It also allows for mocking in tests of the Logback reset mechanisms and extensions.
Since it gets mocked, it's never tested. So, this tests it. And hey, it could theoretically break if someone changed it to return null!
This method is mocked in other tests, so is never exercised. Test the delegation to LogbackTestHelpers by passing arguments that don't exist, and validating the exception we get. Kind of invasive but gets the job done without actually resetting Logback, which we generally want to avoid.
sleberknight
changed the title
Create utils and Jupter extension to reset Logback
Create utils and Jupiter extension to reset Logback
Feb 10, 2024
Quality Gate passedIssues Measures |
chrisrohr
approved these changes
Feb 10, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #460
Closes #461